I'm trying some code, but without success for now...alpha24 wrote: Sat Aug 12, 2023 9:29 pm Dear Ogee,
Same problem with your given indicator. I am comfortable with Tick Volume Indicator I just want that color change if current bar is greater than previous bar should show green and vice versa. If our Masters make this code as I wish will be great.
Re: Coding Help
1532Hello teacher. I had sent you a message in the private chat. Is it not possible to do that project? I really need it. It really works.
Re: Coding Help
1533Hi everyone. Please, I have an mt5 EA I am coding but for some reason the trailing stop function just isn't working. The trailing stop functions is below. I have no errors or warnings in my code. Is the function correct or am I just not calling the function in the appropriate place? Any help would be much appreciated.
Full EA code attached below.
Full EA code attached below.
Code: Select all
void ApplyTrailingStop()
{
if(!PositionSelect(Symbol())) return; // If no position for this symbol, exit the function
double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);
double currentPrice = SymbolInfoDouble(Symbol(), (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) ? SYMBOL_BID : SYMBOL_ASK);
double trailingStopInPoints = 10; // 15 pips = 150 points
double distanceToTrail = trailingStopInPoints * SymbolInfoDouble(Symbol(), SYMBOL_POINT);
double currentStopLoss = PositionGetDouble(POSITION_SL);
double newStopLoss = 0;
if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
{
newStopLoss = currentPrice - distanceToTrail;
if(currentStopLoss < newStopLoss || currentStopLoss == 0)
{
trade.PositionModify(Symbol(), newStopLoss, PositionGetDouble(POSITION_TP));
}
}
else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
{
newStopLoss = currentPrice + distanceToTrail;
if(currentStopLoss > newStopLoss || currentStopLoss == 0)
{
trade.PositionModify(Symbol(), newStopLoss, PositionGetDouble(POSITION_TP));
}
}
}
Re: Coding Help
1534Not very familiar with mt5 EA's so just guessing here, maybe tryDaffyTaffy wrote: Sun Sep 10, 2023 5:36 pm Hi everyone. Please, I have an mt5 EA I am coding but for some reason the trailing stop function just isn't working. The trailing stop functions is below. I have no errors or warnings in my code. Is the function correct or am I just not calling the function in the appropriate place? Any help would be much appreciated.
Full EA code attached below.
Code: Select all
void ApplyTrailingStop() { if(!PositionSelect(Symbol())) return; // If no position for this symbol, exit the function double openPrice = PositionGetDouble(POSITION_PRICE_OPEN); double currentPrice = SymbolInfoDouble(Symbol(), (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) ? SYMBOL_BID : SYMBOL_ASK); double trailingStopInPoints = 10; // 15 pips = 150 points double distanceToTrail = trailingStopInPoints * SymbolInfoDouble(Symbol(), SYMBOL_POINT); double currentStopLoss = PositionGetDouble(POSITION_SL); double newStopLoss = 0; if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) { newStopLoss = currentPrice - distanceToTrail; if(currentStopLoss < newStopLoss || currentStopLoss == 0) { trade.PositionModify(Symbol(), newStopLoss, PositionGetDouble(POSITION_TP)); } } else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) { newStopLoss = currentPrice + distanceToTrail; if(currentStopLoss > newStopLoss || currentStopLoss == 0) { trade.PositionModify(Symbol(), newStopLoss, PositionGetDouble(POSITION_TP)); } } }
Code: Select all
if (trailingStopLossPercent>0) ApplyTrailingStop();
- These users thanked the author mrtools for the post:
- DaffyTaffy
Re: Coding Help
1535Thank you so much for responding. I've added that line of code and forward testing it. Hopefully it works.mrtools wrote: Mon Sep 11, 2023 2:53 am Not very familiar with mt5 EA's so just guessing here, maybe try
Hope this helps, but not really for sure.Code: Select all
if (trailingStopLossPercent>0) ApplyTrailingStop();
Re: Coding Help
1536
Hi Mr.Tools. It worked. The issue came from where I called the function. I placed it right after the buy and sell conditions, then I added conditions to check if the trade was in a certain amount of profit. And that seemed to do the trick.mrtools wrote: Mon Sep 11, 2023 2:53 amCode: Select all
if (trailingStopLossPercent>0) ApplyTrailingStop();
Thank you!
- These users thanked the author DaffyTaffy for the post (total 2):
- Jimmy, mrtools
Re: Coding Help
1537Code: Select all
void go_alerts(string msg)
{
Alert(msg);
SendNotification("msg");
}
But I would like to send the symbol and time.
Thanks!
Re: Coding Help
1538Maybe something likeTradehunter wrote: Sat Sep 23, 2023 1:23 amIm trying to add push notifications to this, it works.Code: Select all
void go_alerts(string msg) { Alert(msg); SendNotification("msg"); }
But I would like to send the symbol and time.
Thanks!
Code: Select all
void go_alerts(string msg)
{
msg = timeFrameToString(_Period)+" "+_Symbol+" at "+TimeToString(TimeLocal(),TIME_SECONDS)+" indicator name "+doWhat;
Alert(msg);
SendNotification("msg");
}
- These users thanked the author mrtools for the post:
- Tradehunter
Re: Coding Help
1539
Hello,
I would like to ask maybe some can help me and add arrows or any kind of symbol to Absolute Strength Oscillator as shown in the attached photo?
Thank you very much for your time.
I would like to ask maybe some can help me and add arrows or any kind of symbol to Absolute Strength Oscillator as shown in the attached photo?
Thank you very much for your time.
Re: Coding Help
1540try...ArtūrasF wrote: Sun Sep 24, 2023 12:37 am Hello,
I would like to ask maybe some can help me and add arrows or any kind of symbol to Absolute Strength Oscillator as shown in the attached photo?
Thank you very much for your time.