stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Basic help please
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1321
Page 1 of 1
Author:  censura [ Wed Dec 19, 2012 1:45 pm ]
Post subject:  Basic help please

I am trying to use the Daily Pivot (DP) as a stoploss in the ea i am developing. So far I have used a fixed stoploss (LossLimit) and take profit(ProfitMade) and it is trading fine. I want to test using the DP as the stop loss.

I get the distance values of current price from DP from a DWMP 10.3 10.4 indicator via global variables

But when I try and use this code to set the TP it keeps posting 0.000.

Help would be appritiated

Thank you

Code
if(LossLimit==0 && ProfitMade==0) break;
double stop1 = MathAbs(GlobalVariableGet(Symbol()+"distance"));
// this are values taken from DWMP 10.3 10.4 indicator //

if (stop1 < 15 ) stop1 = 15;


SL=stop1;
if(ProfitMade ==0) TP=0;
SL=Bid-((LossLimit)*myPoint );
if(ProfitMade >0) TP=Ask+((ProfitMade)*myPoint );
OrderModify(ticket,OrderOpenPrice(),SL,TP,0,White);
gle=GetLastError();

if(gle==0)
{
logwrite(TradeComment,"BUY MODIFIED Ticket="+ticket+" Ask="+Ask+" Lots="+lotsi+" SL="+SL+" TP="+TP);TradeAllowed=false;
break;
}
else
{
logwrite(TradeComment,"-----ERROR----- Modifying BUY order: Lots="+lotsi+" SL="+SL+" TP="+TP+" Bid="+Bid+" Ask="+Ask+" ticket="+ticket+" Err="+gle+" "+ErrorDescription(gle));

RefreshRates();
Sleep(500);

loopcount++;
if(loopcount>maxloop)
{
logwrite(TradeComment,"-----ERROR----- Giving up on modifying BUY order");
return(gle);
}
}
}//while - modify order

Sleep(1800000);
}//BUYme
Author:  gaheitman [ Wed Dec 19, 2012 8:30 pm ]
Post subject:  Re: Basic help please

In your code, you aren't actually using the stop1 value to calculate SL. Your initial assignment

Code: Select all

SL=stop1;
is overwritten by

Code: Select all

SL=Bid-((LossLimit)*myPoint );
George
Author:  garyfritz [ Thu Dec 20, 2012 11:07 pm ]
Post subject:  Re: Basic help please

censura wrote:But when I try and use this code to set the TP it keeps posting 0.000.
Are you sure ProfitMade is > 0? If ProfitMade == 0, TP will be 0.00 ...
All times are UTC Page 1 of 1