Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us

Share your knowledge in the forex community!

Our community is a completely independent place for communication between forex traders and software developers for trading platforms Metatrader 4 and Metatrader 5

Create A New Account
Home/ Questions/Q 5885
Next
In Process
artur50000
artur50000

artur50000

  • 1 Question
  • 1 Answer
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
artur50000
Asked: December 29, 20202020-12-29T10:13:16+00:00 2020-12-29T10:13:16+00:00In: Forex Expert Advisors

question from a beginner on negative trades with open orders

  • 0

Good afternoon!
In Alpari on MT5, I generated an expert Advisor based on RSI signals. I started it and there was a problem: 

an automatic Expert Advisor opens orders on a demo account. And with open orders in the history, sometimes negative trades occur, and at the same time the stop loss is either not set, or it is still very far away. what could it be? On the account of 10000 usd, the leverage is 1:1. the lot size is 0.01

  • 3 3 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    3 Answers

    • Voted
    • Oldest
    • Recent
    1. vlad143

      vlad143

      • 0 Questions
      • 6 Answers
      • 0 Best Answers
      • 32 Points
      View Profile
      vlad143
      2020-12-29T10:13:34+00:00Added an answer on December 29, 2020 at 10:13 am

      artur50000:

      Good afternoon!

      In Alpari on MT5, I generated an expert Advisor based on RSI signals. I started it and there was a problem: 

      an automatic Expert Advisor opens orders on a demo account. And with open orders in the history, sometimes negative trades occur, and at the same time the stop loss is either not set, or it is still very far away. what could it be? On the account of 10000 usd, the leverage is 1:1. the lot size is 0.01

      At the moment of opening any trade, there is a jump in the spread to the loss area. Opening Buy at the Ask rate, we immediately get the current rate at which the transaction can be closed, equal to Bid, which is worse than Ask for the spread. Are you talking about such disadvantages? How do they relate to setting a stop loss, deposit, leverage, and lot?

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. artur50000

      artur50000

      • 1 Question
      • 1 Answer
      • 0 Best Answers
      • 20 Points
      View Profile
      artur50000
      2020-12-29T10:13:29+00:00Added an answer on December 29, 2020 at 10:13 am

      I don’t think it’s the signals at all. when I put an Expert Advisor based on the MACD, it was all the same. I want to emphasize once again that a negative entry in the history occurs when

      OPEN order. The order itself is closed by take profit on the total.

      account details:

      Account Type: demo.ecn.mt5
      Trading Server: AlpariEurasia-MT5-Demo
      Trading Platform: MetaTrader 5
      Leverage: 1:1To change

      I trade on the five-minute frame EURUSD, GBPUSD after six in the evening in Moscow.

      Here is the code of the RSI Expert Advisor:

      #include

      //— available money management

      #include

      //+——————————————————————+

      //| Inputs                                                           |

      //+——————————————————————+

      //— inputs for expert

      input string             Expert_Title         =”art6″;      // Document name

      ulong                    Expert_MagicNumber   =32023;       // 

      bool                     Expert_EveryTick     =false;       // 

      //— inputs for main signal

      input int                Signal_ThresholdOpen =10;          // Signal threshold value to open [0…100]

      input int                Signal_ThresholdClose=10;          // Signal threshold value to close [0…100]

      input double             Signal_PriceLevel    =0.0;         // Price level to execute a deal

      input double             Signal_StopLevel     =50.0;        // Stop Loss level (in points)

      input double             Signal_TakeLevel     =0.50;        // Take Profit level (in points)

      input int                Signal_Expiration    =4;           // Expiration of pending orders (in bars)

      input int                Signal_RSI_PeriodRSI =8;           // Relative Strength Index(8,…) Period of calculation

      input ENUM_APPLIED_PRICE Signal_RSI_Applied   =PRICE_CLOSE; // Relative Strength Index(8,…) Prices series

      input double             Signal_RSI_Weight    =1.0;         // Relative Strength Index(8,…) Weight [0…1.0]

      //— inputs for money

      input double             Money_FixLot_Percent =10.0;        // Percent

      input double             Money_FixLot_Lots    =0.1;         // Fixed volume

      //+——————————————————————+

      //| Global expert object                                             |

      //+——————————————————————+

      CExpert ExtExpert;

      //+——————————————————————+

      //| Initialization function of the expert                            |

      //+——————————————————————+

      int OnInit()

        {

      //— Initializing expert

         if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))

           {

            //— failed

            printf(__FUNCTION__+”: error initializing expert”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— Creating signal

         CExpertSignal *signal=new CExpertSignal;

         if(signal==NULL)

           {

            //— failed

            printf(__FUNCTION__+”: error creating signal”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //—

         ExtExpert.InitSignal(signal);

         signal.ThresholdOpen(Signal_ThresholdOpen);

         signal.ThresholdClose(Signal_ThresholdClose);

         signal.PriceLevel(Signal_PriceLevel);

         signal.StopLevel(Signal_StopLevel);

         signal.TakeLevel(Signal_TakeLevel);

         signal.Expiration(Signal_Expiration);

      //— Creating filter CSignalRSI

         CSignalRSI *filter0=new CSignalRSI;

         if(filter0==NULL)

           {

            //— failed

            printf(__FUNCTION__+”: error creating filter0″);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

         signal.AddFilter(filter0);

      //— Set filter parameters

         filter0.PeriodRSI(Signal_RSI_PeriodRSI);

         filter0.Applied(Signal_RSI_Applied);

         filter0.Weight(Signal_RSI_Weight);

      //— Creation of trailing object

         CTrailingNone *trailing=new CTrailingNone;

         if(trailing==NULL)

           {

            //— failed

            printf(__FUNCTION__+”: error creating trailing”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— Add trailing to expert (will be deleted automatically))

         if(!ExtExpert.InitTrailing(trailing))

           {

            //— failed

            printf(__FUNCTION__+”: error initializing trailing”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— Set trailing parameters

      //— Creation of money object

         CMoneyFixedLot *money=new CMoneyFixedLot;

         if(money==NULL)

           {

            //— failed

            printf(__FUNCTION__+”: error creating money”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— Add money to expert (will be deleted automatically))

         if(!ExtExpert.InitMoney(money))

           {

            //— failed

            printf(__FUNCTION__+”: error initializing money”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— Set money parameters

         money.Percent(Money_FixLot_Percent);

         money.Lots(Money_FixLot_Lots);

      //— Check all trading objects parameters

         if(!ExtExpert.ValidationSettings())

           {

            //— failed

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— Tuning of all necessary indicators

         if(!ExtExpert.InitIndicators())

           {

            //— failed

            printf(__FUNCTION__+”: error initializing indicators”);

            ExtExpert.Deinit();

            return(INIT_FAILED);

           }

      //— ok

         return(INIT_SUCCEEDED);

        }

      //+——————————————————————+

      //| Deinitialization function of the expert                          |

      //+——————————————————————+

      void OnDeinit(const int reason)

        {

         ExtExpert.Deinit();

        }

      //+——————————————————————+

      //| “Tick” event handler function                                    |

      //+——————————————————————+

      void OnTick()

        {

         ExtExpert.OnTick();

        }

      //+——————————————————————+

      //| “Trade” event handler function                                   |

      //+——————————————————————+

      void OnTrade()

        {

         ExtExpert.OnTrade();

        }

      //+——————————————————————+

      //| “Timer” event handler function                                   |

      //+——————————————————————+

      void OnTimer()

        {

         ExtExpert.OnTimer();

        }

      //+——————————————————————+

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. barabashkakvn

      barabashkakvn

      • 8 Questions
      • 171 Answers
      • 0 Best Answers
      • 352 Points
      View Profile
      barabashkakvn
      2020-12-29T10:13:21+00:00Added an answer on December 29, 2020 at 10:13 am
      question from a beginner on negative trades with open orders

      artur50000:

      Good afternoon!

      In Alpari on MT5, I generated an expert Advisor based on RSI signals. I started it and there was a problem: 

      an automatic Expert Advisor opens orders on a demo account. And with open orders in the history, sometimes negative trades occur, and at the same time the stop loss is either not set, or it is still very far away. what could it be? On the account of 10000 usd, the leverage is 1:1. the lot size is 0.01

      RSI trading signals.

      Look at these signals, as well as the weights of the signals in your code. Also an article for review: 

      MQL5 Wizard: New version

      Improvements continue to be made to the MetaTrader 5 terminal, and new functionality is being added. In the next (439) build of MetaTrader 5, the MQL5 Wizard has also been updated, which allows you to create Expert Advisors with even more flexible trading rules. In this article, we will show the new features of the MQL5 Wizard and tell you about the changes in the architecture of experts obtained when using it. From the very beginning, the MQL5 Wizard was conceived as a tool for easy creation of programs in MQL5. Already in the first version of the MQL5 Wizard, it was possible to quickly create a ready-to-use Expert Advisor as a set of simple modules in the form of source code in the MQL5 language. To do this, you did not even need to know the MQL5 language, it was enough to read the article “Build your trading advisor in the MQL5 Wizard”. In total, the Expert Advisor generated by the Master contains three modules: the trading signals module; the position tracking module; and the capital and risk management module. Each Expert Advisor module is based on its own…

      Articles | 2011.04.27 18: 07 | MetaQuotes Software Corp. | Trading | MetaTrader 5

      When will you get acquainted and if there are any questions:

      • specify the type of your trading account (netting or henge)
      • specify the symbol, timeframe, and date period on which you are testing
      • provide the Expert Advisor code generated by the MQL5 wizard
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 514
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 921
    • Popular
    • Answers
    • Tags
      • On: December 18, 2020
      • Answers: 16

      How to allow trading at certain times

      • On: December 29, 2020
      • Answers: 16

      Example of implementing the OOP pattern Abstract Factory using MQL5 ...

      • On: December 18, 2020
      • Answers: 15

      EMA with a different formula

      • On: December 29, 2020
      • Answers: 15

      Invitation for algo traders.

      • On: December 29, 2020
      • Answers: 14

      Dear Programmers, do not pass by, help fix the error!

    • atma1
      atma1 added an answer Added activation. Thanks. April 8, 2021 at 6:54 am
    • iks_
      iks_ added an answer Atma1: Good day, dear colleagues. Yesterday I updated VMware to… April 8, 2021 at 6:54 am
    • renat
      renat added an answer Atma1: Good day, dear colleagues. Yesterday I updated VMware to… April 8, 2021 at 6:54 am
    • mvs
      mvs added an answer Renat Fatkhullin: You can not immediately send the received data,… April 8, 2021 at 6:53 am
    • anton_m
      anton_m added an answer Renat Fatkhullin: How much data do you read? You can… April 8, 2021 at 6:53 am
    analytics british company computer developers django employee employer english facebook french google interview javascript language life php proforexea programmer programs pro vsa salary university

    Related Questions

    • atma1

      Yesterday I updated VMware to version 16.1.0 and the product ...

      • 3 Answers
    • anton_m

      It is not possible to read data from the server ...

      • 6 Answers
    • s22aa

      Tell me what the difference is.

      • 2 Answers
    • areedbreen

      on the chart in the tester one yield and in ...

      • 2 Answers
    • 1006293

      A question about the intersection of moving averages in MQL5

      • 3 Answers

    Users

    atma1

    atma1

    • 1 Question
    • 1 Answer
    s22aa

    s22aa

    • 1 Question
    • 1 Answer
    areedbreen

    areedbreen

    • 1 Question
    • 1 Answer

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved