Need some help please

Post Reply
xfactornos
Trader
Posts: 115
Joined: Fri May 23, 2014 5:43 pm
Location: Where I am...

Need some help please

Post by xfactornos »

Hey guys,

I am trying to automate my indicator and its kicking my ass!!!! Its so frustrating because it seems so simple but I cant get it to work.

First off,
About the indicator, Its something I coded, and it draws the arrows correctly. All it does is draw an arrow when i tell it to. so, When there is a buy situation, a buy arrow goes in Buffer 0, when there is a sell situation a sell arrow goes in buffer 1. When there is no signal the buffers read 0.0000.

easy enough right? thats what i thought too but I cant get it to work right.

ALL i want it to do is, IF value is non empty in the buffer, to place the trade.
Logic.... if there is a value there, that means there is an arrow.

Once again easy....

so, I looked at Steve's HGI bot because its the same idea. If there is something in the buffer place the trade. I have tried so many different methods that I'm just beyond pissed and hence why I'm asking for help.

THE PROBLEM:

It seems to place buy and or sell trades whenever the hell it feels like it. I even create an alert for debugging to spit out the values being read, and they state 0 when a trade is placed.

I shift over 1, because the arrow paints a candle behind, never on the current candle...
The code, keep in mind i modeled the HGI code.

Code: Select all

      //Indi reading code goes here 
          if (TrendTradingAllowed)
         {
            //Buffer 0 holds a buy trend arrow - large green up
            val = GetKING(Symbol(), TradingTimeFrame, 0, 1);
             Alert(" Buy Value = ",val);
            if (!CloseEnough(val, EMPTY_VALUE) )
            {
               GoodToRise = True;
            }//if (!CloseEnough(val 0) )         
            else 
            {
               //Buffer 1 hods a sell trend arrrow - large red down
               val = GetKING(Symbol(), TradingTimeFrame, 1, 1);
               Alert(" Sell Value = ",val);
               if (!CloseEnough(val, EMPTY_VALUE) )
               {
                  GoodToFall = True;
               }//if (!CloseEnough(val 0) 
            }//else
         }//if (TrendTradingAllowed)
      ///////////////////////////////////////
      //Anything else?

Code: Select all

double GetKING(string symbol, int tf, int buffer, int shift)
{

   return(iCustom(symbol, tf, "SLOWKING", 5, False, False, buffer, shift));
   
}//double GetKING()

Code: Select all

   bool SendLong = false, SendShort = false;
   
     if (GoodToRise)
     {
     BuySignal = True;
     }

   //Trend Sell
    if (GoodToFall)
     {
     SellSignal = True;
    }
   //Specific system filters
Does anyone see anything obviously wrong here?

I just want to buy when there is an arrow(value) in buffer 0, and sell when there is an arrow(value) in buffer 1.

Thanks for any input guys.
John 3:16
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Need some help please

Post by renexxxx »

These code snippets are not long enough to find the bug. I don't see for instance where and if you set GoodToRise and GoodToFall to false. If you never (re)initialize these flags they will always stay true, once they have been set to true. You may also want to consider to make these flags local variables if they don't have to be global. But attach the complete script if you want some more help.

René
xfactornos
Trader
Posts: 115
Joined: Fri May 23, 2014 5:43 pm
Location: Where I am...

Need some help please

Post by xfactornos »

Sorry René,

See attached
You do not have the required permissions to view the files attached to this post.
John 3:16
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Need some help please

Post by SteveHopwood »

xfactornos » Mon Dec 28, 2015 8:48 pm wrote:Sorry René,

See attached
Good to see you trying this for yourself.

You really need to take on board Rene's previous post. If you never reset a variable to false, then once true it will be true until you next reset your platform. I have not looked at your code but would happily bet a fiver that you have made just this sort of mistake.

Guess how I know? :oops:

:xm:

Hint: if a variable needs to be set to 'true' once something or other is calculated, then set it to 'false' before entering the calculation.
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Need some help please

Post by renexxxx »

I don't have access to a PC at the moment as I am travelling in the Netherlands and could only look at your code on a phone, but what struck me immediately is that GoodToRise and GoodToFall are declared as doubles and later on treated as booleans. This won't work, and must be corrected first. I can not say whether the rest of the code is correct, but good luck with it.
xfactornos
Trader
Posts: 115
Joined: Fri May 23, 2014 5:43 pm
Location: Where I am...

Need some help please

Post by xfactornos »

Thanks guys :hi:
John 3:16
Post Reply

Return to “Coders Hangout”