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
Basic help please
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: Basic help please
In your code, you aren't actually using the stop1 value to calculate SL. Your initial assignment
is overwritten by
George
Code: Select all
SL=stop1;Code: Select all
SL=Bid-((LossLimit)*myPoint );-
garyfritz
Re: Basic help please
Are you sure ProfitMade is > 0? If ProfitMade == 0, TP will be 0.00 ...censura wrote:But when I try and use this code to set the TP it keeps posting 0.000.