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
Home/ Questions/Q 5601
Next
In Process
boski
boski

boski

  • 1 Question
  • 2 Answers
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
boski
Asked: December 29, 20202020-12-29T09:56:01+00:00 2020-12-29T09:56:01+00:00In: Forex Expert Advisors

Checking the correctness of the code

  • 0

I would like to ask experienced programmers to tell me what is written incorrectly.
Now I will describe first how everything should actually work:
  





1) Waiting for the candle to close:
1.1) If it closed and we determined that the candle is bullish (bearish), we check 1.2
1.2) Calculate the size of the candle
1.3) Open 2 trades (1 buy,1 sell) if the candle size is equal to the specified range specified in the input parameters. (If the candle is bearish, we open a buy at 0.03 sell at 0.01, for a bullish candle, the opposite is true)
2) The logic of opening the following positions ( taking into account the fact that the candle was bearish) 
2.1) Open trades buy_1 at 0.03
                             sell_1 by 0.01
2.2) If the buy stop loss trade is closed, we open another buy_2 trade with a double lot from the initial volume and 1 sell_2 trade with a double volume
2.3) If the sell is closed by stop loss, we do not do anything, we wait for the sell to close
2.3) If buy_2 closed on stop loss then open sell_3 volume = (buy_1+buy_2+sell_1+sell_2)
2.4) We do not take into account the closing of the stop loss, when the stop loss leads to a positive result because the trailing stop was moved 
2.5) When closing any trade on takeprofit then do nothing waiting for the signal
I will attach parts of the code below . 

  • 4 4 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    4 Answers

    • Voted
    • Oldest
    • Recent
    1. barabashkakvn

      barabashkakvn

      • 7 Questions
      • 162 Answers
      • 0 Best Answers
      • 314 Points
      View Profile
      barabashkakvn
      2020-12-29T09:56:28+00:00Added an answer on December 29, 2020 at 9:56 am

      Kirill Andreev:

          ***

      here is the input :

       

      input int bars_points=120; / / maximum bar size
      input int bars_points_1=80; / / minimum bar size

      It is better to immediately name the parameters so that they carry a semantic load. Instead of bars_points and bars_points_1:

      minimum_size_bar and maximum_size_bar 

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

      boski

      • 1 Question
      • 2 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      boski
      2020-12-29T09:56:20+00:00Added an answer on December 29, 2020 at 9:56 am

      Vladimir Karputov:

      “bar_1” and “bar” are the input parameters of the first and second bar?

      Like this:

      int val_1=false;

      you can’t write. It is necessary so:

      bool val_1=false;

       

          no, these are not input parameters 

       

       

      double bar=bars_points*_Point;
      double bar_1=bars_points_1*_Point;

         

      here is the input :

       

      input int bars_points=120; / / maximum bar size
      input int bars_points_1=80; / / minimum bar size

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

      barabashkakvn

      • 7 Questions
      • 162 Answers
      • 0 Best Answers
      • 314 Points
      View Profile
      barabashkakvn
      2020-12-29T09:56:12+00:00Added an answer on December 29, 2020 at 9:56 am

      Kirill Andreev:

      Determine the type of candle and check whether it matches the range of the candle.

      // getting the opening and closing difference..
      bool BarsSignal_buy(int SSP=1)
        {
         double AvgRange;
         int val=false;

         AvgRange=MathAbs(iClose(SSP)-iOpen(SSP));

         if(AvgRange>=bar_1 && AvgRange<=bar)// 
           {
            if(Candle_type_sell(1))
               val=true;
            else

               val=false;
           }
         return(val);
        }
      //+——————————————————————+
      // getting the opening and closing difference..
      bool BarsSignal_sell(int SSP=1)
        {
         double AvgRange_1;
         int val_1=false;

         AvgRange_1=MathAbs(iClose(SSP)-iOpen(SSP));

         if(AvgRange_1>=bar_1 && AvgRange_1<=bar)// bar= 0.001
           {
            if(Candle_type_buy(1))
               val_1=true;
            else
               val_1=false;
           }
         return(val_1);
        }

      “bar_1” and “bar” are the input parameters of the first and second bar?

      Like this:

      int val_1=false;

      you can’t write. It is necessary so:

      bool val_1=false;

       

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. boski

      boski

      • 1 Question
      • 2 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      boski
      2020-12-29T09:56:05+00:00Added an answer on December 29, 2020 at 9:56 am

      Determine the type of candle and check whether it matches the range of the candle.

      // getting the opening and closing difference..
      bool BarsSignal_buy(int SSP=1)
        {
         double AvgRange;
         int val=false;

         AvgRange=MathAbs(iClose(SSP)-iOpen(SSP));

         if(AvgRange>=bar_1 && AvgRange<=bar)// 
           {
            if(Candle_type_sell(1))
               val=true;
            else

               val=false;
           }
         return(val);
        }
      //+——————————————————————+
      // getting the opening and closing difference..
      bool BarsSignal_sell(int SSP=1)
        {
         double AvgRange_1;
         int val_1=false;

         AvgRange_1=MathAbs(iClose(SSP)-iOpen(SSP));

         if(AvgRange_1>=bar_1 && AvgRange_1<=bar)// bar= 0.001
           {
            if(Candle_type_buy(1))
               val_1=true;
            else
               val_1=false;
           }
         return(val_1);
        }

      • 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 504
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 681
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Related Questions

    • Brus Agell

      Правельный выбор

      • 0 Answers
    • pinupcasinoo

      Pin Up Casino

      • 0 Answers
    • c00l777

      During optimization, indicators that are not present in the robot ...

      • 2 Answers
    • c00l777

      During optimization, indicators that are not present in the robot ...

      • 0 Answers
    • c00l777

      Optimization results differ on different accounts

      • 3 Answers

    Users

    Leonardcig

    Leonardcig

    • 0 Questions
    • 0 Answers
    DennisByday

    DennisByday

    • 0 Questions
    • 0 Answers
    Haroldmeary

    Haroldmeary

    • 0 Questions
    • 0 Answers

    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