I need help editing an existing code. I would like my order to go off at a fixed price. example if GBPUSD hits 1.35420 my order opens.

MQL4 Indikatoren Experten

Spezifikation

the sl doesnt work  i want the tp logic to remain

i need the trend direction fucntion tow ork i the trend is up then only buys if down only sells

i need the fibo nacci fucntion to work as well

and the flat zone function to work as well


and i need the code to trade 1% of the balance 


//+------------------------------------------------------------------+

//|                                                   US500_EA.mq4   |

//|                                  Copyright 2024, MetaQuotes Ltd. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2024, MetaQuotes Ltd."

#property link      "https://www.mql5.com"

#property version   "1.07"

#property strict


// Input parameters

extern int SMA14_Period = 14;

extern int SMA50_Period = 50;

extern int SMA100_Period = 100;

extern int DistinctTrend_Period = 10; // Period for detecting distinct trend

extern int FlatRange_Period = 5;      // Period for detecting flat range

extern int MagicNumber = 12345;


// Global variables for trading

double sma14, sma50, sma100;

double upper15Percent, lower15Percent;


// Constants for US500 on IC Markets

const string SYMBOL = "US500";

const double LOT_SIZE = 1.0;

const double POINT_VALUE = 0.1; // Adjust this based on IC Markets' US500 contract specifications

const double STOP_LOSS_POINTS = 1.75; // Stop loss in points

const double TAKE_PROFIT_POINTS = 1.5; // Take profit in points


// Line names for chart objects

const string SMA14_LINE = "SMA14_Line";

const string SMA50_LINE = "SMA50_Line";

const string SMA100_LINE = "SMA100_Line";


//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

{

    // Check if the current symbol is US500

    if (Symbol() != SYMBOL)

    {

        Print("This EA is designed to work only with ", SYMBOL);

        return INIT_FAILED;

    }


    return(INIT_SUCCEEDED);

}


//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

    // Remove all chart objects created by this EA

    ObjectsDeleteAll(0, OBJ_TREND);

}


//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

{

    // Calculate and draw SMAs

    CalculateAndDrawIndicators();


    // Check if there's already an open trade

    if (IsTradeOpen())

    {

        return; // Exit the function as we don't want to open new trades

    }


    // Determine market conditions

    double highestHigh = High[iHighest(NULL, 0, MODE_HIGH, 100, 0)];

    double lowestLow = Low[iLowest(NULL, 0, MODE_LOW, 100, 0)];

    double range = highestHigh - lowestLow;

    upper15Percent = highestHigh - 0.15 * range;

    lower15Percent = lowestLow + 0.15 * range;


    bool distinctUptrend = IsDistinctTrend(1);

    bool distinctDowntrend = IsDistinctTrend(-1);

    bool inFibZone = (Bid >= upper15Percent || Bid <= lower15Percent);

    double currentSpread = MarketInfo(Symbol(), MODE_SPREAD) * POINT_VALUE;


    // Trading logic

    if (sma14 > sma50 && distinctUptrend && !inFibZone && !IsFlatRange())

    {

        OpenOrder(OP_BUY, currentSpread);

    }

    else if (sma14 < sma50 && distinctDowntrend && !inFibZone && !IsFlatRange())

    {

        OpenOrder(OP_SELL, currentSpread);

    }

}


//+------------------------------------------------------------------+

//| Calculate and draw SMAs                                          |

//+------------------------------------------------------------------+

void CalculateAndDrawIndicators()

{

    int draw_begin = Bars - 1000; // Draw for the last 1000 bars

    

    // Calculate current SMA values

    sma14 = iMA(NULL, 0, SMA14_Period, 0, MODE_SMA, PRICE_CLOSE, 0);

    sma50 = iMA(NULL, 0, SMA50_Period, 0, MODE_SMA, PRICE_CLOSE, 0);

    sma100 = iMA(NULL, 0, SMA100_Period, 0, MODE_SMA, PRICE_CLOSE, 0);

    

    DrawSMA(SMA14_LINE, SMA14_Period, draw_begin, Blue);

    DrawSMA(SMA50_LINE, SMA50_Period, draw_begin, Red);

    DrawSMA(SMA100_LINE, SMA100_Period, draw_begin, Green);

}


//+------------------------------------------------------------------+

//| Draw an SMA line on the chart                                    |

//+------------------------------------------------------------------+

void DrawSMA(const string name, const int period, const int draw_begin, const color line_color)

{

    ObjectDelete(name);

    ObjectCreate(name, OBJ_TREND, 0, Time[draw_begin], iMA(NULL, 0, period, 0, MODE_SMA, PRICE_CLOSE, draw_begin), 

                 Time[0], iMA(NULL, 0, period, 0, MODE_SMA, PRICE_CLOSE, 0));

    ObjectSetInteger(0, name, OBJPROP_COLOR, line_color);

    ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);

    ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, true);

}


//+------------------------------------------------------------------+

//| Check if the market is in a distinct trend                       |

//+------------------------------------------------------------------+

bool IsDistinctTrend(int direction)

{

    for (int i = 1; i <= DistinctTrend_Period; i++)

    {

        double previousSMA100 = iMA(NULL, 0, SMA100_Period, 0, MODE_SMA, PRICE_CLOSE, i);

        if (direction * (sma100 - previousSMA100) <= 0)

            return false;

    }

    return true;

}


//+------------------------------------------------------------------+

//| Check if the market is in a flat range                           |

//+------------------------------------------------------------------+

bool IsFlatRange()

{

    double previousSMA100 = iMA(NULL, 0, SMA100_Period, 0, MODE_SMA, PRICE_CLOSE, 1);

    double previousSMA50 = iMA(NULL, 0, SMA50_Period, 0, MODE_SMA, PRICE_CLOSE, 1);

    

    return (MathAbs(sma100 - sma50) < FlatRange_Period * POINT_VALUE &&

            MathAbs(sma100 - previousSMA100) < 0.001 &&

            MathAbs(sma50 - previousSMA50) < 0.001);

}


//+------------------------------------------------------------------+

//| Open an order                                                    |

//+------------------------------------------------------------------+

void OpenOrder(int orderType, double spread)

{

    // First, check if there's already an open trade

    if (IsTradeOpen())

    {

        Print("A trade is already open. Skipping new order.");

        return;

    }


    double price = (orderType == OP_BUY) ? Ask : Bid;

    

    // Calculate stop loss: 1.75 points plus spread

    double stopLossDistance = STOP_LOSS_POINTS * POINT_VALUE + spread;

    double stopLoss = (orderType == OP_BUY) ? NormalizeDouble(price - stopLossDistance, Digits)

                                            : NormalizeDouble(price + stopLossDistance, Digits);

    

    // Calculate take profit: 1.5 points net

    double takeProfitDistance = TAKE_PROFIT_POINTS * POINT_VALUE + spread; // Adding spread to make it net

    double takeProfit = (orderType == OP_BUY) ? NormalizeDouble(price + takeProfitDistance, Digits)

                                              : NormalizeDouble(price - takeProfitDistance, Digits);


    int ticket = OrderSend(SYMBOL, orderType, LOT_SIZE, price, 3, stopLoss, takeProfit, "US500 Order", MagicNumber, 0, clrGreen);

    if (ticket < 0) 

    {

        Print("OrderSend failed with error #", GetLastError());

    }

    else

    {

        Print("Order opened successfully. Ticket: ", ticket, ", Stop Loss: ", stopLoss, ", Take Profit: ", takeProfit);

    }

}


//+------------------------------------------------------------------+

//| Check if there's an open trade                                   |

//+------------------------------------------------------------------+

bool IsTradeOpen()

{

    for (int i = 0; i < OrdersTotal(); i++)

    {

        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

        {

            if (OrderSymbol() == SYMBOL && OrderMagicNumber() == MagicNumber)

            {

                return true;

            }

        }

    }

    return false;

}

Bewerbungen

1
Entwickler 1
Bewertung
(1)
Projekte
3
0%
Schlichtung
0
Frist nicht eingehalten
0
Arbeitet
2
Entwickler 2
Bewertung
(1)
Projekte
1
0%
Schlichtung
0
Frist nicht eingehalten
0
Arbeitet
3
Entwickler 3
Bewertung
(2)
Projekte
1
100%
Schlichtung
1
0% / 100%
Frist nicht eingehalten
0
Frei
Ähnliche Aufträge
I need an indicator based on ICT trading. It must be highly effective and efficient. The indicator must able to analyze the OB, MSS, FVG,$$$. The entry and exit zones must be based on the strategy, it must have arrows for entry and exit
hi i have an indicator all in one level indicator worked for usdcad pair only. any one who can decode and fix to worked all forex pairs and commodities and crypto
I want to add lot Size filter in my MQ5 EA. based on account balance increseing lot size must be increseing and when balance decrese lot size also decresed..that's all i want
FVG Screener 30 - 60 USD
Hi, Greetings. Can somebody code a MT4 MTF Scanner to alert Pairs and Time Frames when a FVG is touched or respected ? I dont need to see the FVG as I do have an indicator to show FVGs on any time frame but you can enable the scanner to show the FVG as well. Kindly advise price. Best Regards. Anton
Hello, ,I will briefly explain what I need, I would like to know if you can make me an indicator for cTrader, for the forex market, that can count the candles starting from the first candle starting at 00:00. Obviously in a 5 minute TF the candle count will be much higher than that of the H1 TF, also I use 250/500/1000 ticks charts, so this indicator should also count the candles of this type of charts I would like a
Sniper EA 70+ USD
I need some help to develop Sniper EA ZAR some one will know to create it please help Robot must trade all currency and any broker 1 to 5 trades daily
I am doing a project in fxdreema in which I am trying to make an EA that detects and draws the bos and choch and also allows the use of other indicators with buttons on the screen... but I can't get it to work correctly to detect the bos and choch and draw them on screen correctly
Billion 30+ USD
I have two powerful mt4 indicators which want you developer to convert it into meta trader five indicators for me to be using it for trading on meta trader five platform
i want a forex robot that will read chats and enter trades on its oown. i want it to be able to use all trading strategies and partterns. good risky manegmemt, i want it to forcuse on Gold and and all major forex pairs. i want it to use stop loses and take profits as the market might change direction anytime. i want to work on both mt5 and mt4
I have access to a paid/subscription TradingView Strategy but I'am unable to see the script/code. I'm looking for someone who is able to reverse engineer this Strategy and create a new version that I would have full access to. I believe this would be using PineScript. If you've done this sort of thing before, please message me. $400 is my budget for this project on completion

Projektdetails

Budget
40+ USD
Ausführungsfristen
bis 1 Tag(e)

Kunde

Veröffentlichte Aufträge4
Anzahl der Schlichtungen0