Not logged in

Forums

Viewing 15 posts - 1 through 15 (of 17 total)
  • #201596 |
    Customer
    90 Posts

    Hi all,

    Is it possible to change the background color of a chart ?

    Regards

    John

    • This topic was modified 7 months, 3 weeks ago by  JS17.
    #201622
    Administrator
    635 Posts

    Hello,

    do you mean MT chart background color? Right click on chart – select Properties and set the color

    #201630
    Customer
    90 Posts

    Tomas,

    Yes

    Attachments:
    You must be logged in to view attached files.
    #201632
    Administrator
    635 Posts

    Did you mean you need to change bckgnd color from within the EA?

    #201633
    Customer
    90 Posts

    Tomas

    Yes please

     

    #201638
    Karish
    Customer
    578 Posts

    //+——————————————————————+
    //| The function receives chart background color.                    |
    //+——————————————————————+
    color ChartBackColorGet(const long chart_ID=0)
    {
    //— prepare the variable to receive the color
    long result=clrNONE;
    //— reset the error value
    ResetLastError();
    //— receive chart background color
    if(!ChartGetInteger(chart_ID,CHART_COLOR_BACKGROUND,0,result))
    {
    //— display the error message in Experts journal
    Print(__FUNCTION__+”, Error Code = “,GetLastError());
    }
    //— return the value of the chart property
    return((color)result);
    }
    //+——————————————————————+
    //| The function sets chart background color.                        |
    //+——————————————————————+
    bool ChartBackColorSet(const color clr,const long chart_ID=0)
    {
    //— reset the error value
    ResetLastError();
    //— set the chart background color
    if(!ChartSetInteger(chart_ID,CHART_COLOR_BACKGROUND,clr))
    {
    //— display the error message in Experts journal
    Print(__FUNCTION__+”, Error Code = “,GetLastError());
    return(false);
    }
    //— successful execution
    return(true);
    }

    #201639
    Customer
    90 Posts

    Karish

    Thanks for the reply but I don’t do any coding at all and I was hoping that it could be done using the EA Wizard

    Thankyou

    #201641
    Karish
    Customer
    578 Posts

    Why would you like to have EA Wiz to change your MT4’s chart background color for, i have trouble to understand

    #201646
    Customer
    90 Posts

    Karish

    I want the background color different if I am in a different trade, Hedge/Buy/Sell etc

    Regards

    John

    #201648
    Administrator
    635 Posts

    Hello,

    you can copy the Karish’s code into EA Wizard / code / CustomFunctions.mq4 (at the end) and save

    In EA WIzard you can reference these using “Custom Action” like

    CustomAction(ChartBackColorSet(white,0));

    It should work

     

    #201678
    Karish
    Customer
    578 Posts

    Put this at the very end of: “EA Wizard / code / CustomFunctions.mq4″

     

    bool ChartBackColorSet(const color clr,const long chart_ID=0)
    {
    //— reset the error value
    ResetLastError();
    //— set the chart background color
    if(!ChartSetInteger(chart_ID,CHART_COLOR_BACKGROUND,clr))
    {
    //— display the error message in Experts journal
    Print(__FUNCTION__+”, Error Code = “,GetLastError());
    return(false);
    }
    //— successful execution
    return(true);
    }

     

    Add this line of code after the OrderSend function ends:

     

    if(OP_BUY){ChartBackColorSet(Green, 0);}

    if(OP_SELL){ChartBackColorSet(Red, 0);}

     

    Im sure you will understand, good luck.

    #201680
    Customer
    90 Posts

    Karish

    Thanks again for your help

    But your faith in my abilities are not well placed – lol

     

    I created a simple EA to test this and used CustomAction inside EA Wizard to change the background color to red if the EA closed all positions on equity target

    When I complied it the editor showed 7 errror messages

    I have attached the EA if you can help?

    Regards

    John

    Attachments:
    You must be logged in to view attached files.
    #201682
    Customer
    90 Posts

    This is the sqw file, just change the file extension back to .sqw and it should be OK

    • This reply was modified 7 months, 3 weeks ago by  JS17.
    #201684
    Customer
    90 Posts

    that did not work, I give up with that  lol

    #202118
    Customer
    90 Posts

    Tomas

    I don’t know were this post above should be ??????????????????, it must be an error

     

    Have you looked at my background color file above yet ???

    Regards

    John

     

    • This reply was modified 7 months, 2 weeks ago by  JS17.
Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.