stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Awesome - original version
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5232
Page 29 of 46
Author:  SteveHopwood [ Sun Sep 10, 2017 2:50 pm ]
Post subject:  Awesome - original version

V 1i is in post 1. I replaced a couple of my more ridiculous indexes with multi-field arrays - something only the coders will see.

More to the point for you guys is the code that Thomas sent me today to tidy up the chart display. Those annoying gaps and places where text is overwritten are all gone. Brilliant. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

You can add the code to any existing EA created from my shells since lifesys sent me the original code. Go to void Display(string text) and copy this over the top of the existing function:

Code: Select all

void Display(string text)
{
  string lab_str = "OAM-" + IntegerToString(DisplayCount);  
  double ofset = 0;
  string textpart[5];
  uint w,h;
  
  for (int cc = 0; cc < 5; cc++)
  {
     textpart[cc] = StringSubstr(text,cc*63,64);
     if (StringLen(textpart[cc]) ==0) continue;
     lab_str = lab_str + IntegerToString(cc);
    
     ObjectCreate(lab_str, OBJ_LABEL, 0, 0, 0);
     ObjectSet(lab_str, OBJPROP_CORNER, 0);
     ObjectSet(lab_str, OBJPROP_XDISTANCE, DisplayX + ofset);
     ObjectSet(lab_str, OBJPROP_YDISTANCE, DisplayY+DisplayCount*(fontSise+4));
     ObjectSet(lab_str, OBJPROP_BACK, false);
     ObjectSetText(lab_str, textpart[cc], fontSise, fontName, colour);
    
     /////////////////////////////////////////////////
     //Calculate label size
     //Tomele supplied this code to eliminate the gaps in the text.
     //Thanks Thomas.
     TextSetFont(fontName,-fontSise*10,0,0);
     TextGetSize(textpart[cc],w,h);
    
     //Trim trailing space
     if (StringSubstr(textpart[cc],63,1)==" ")
        ofset+=(int)(w-fontSise*0.25);
     else
        ofset+=(int)(w-fontSise*0.65);
     /////////////////////////////////////////////////
        
  }//for (int cc = 0; cc < 5; cc++)
}
You can also delete this line of code:
extern double spacingtweek = 0.6; // adjustment to reform lines for different font size
as it is no longer used. Ditto the function string FormatNumber(double x, int width, int precision).

You will find you can have text as large as you can reasonably want it without distorting the display.

Thanks Thomas. You have done as all a huge favour. :clap: :clap: :clap: :clap: :clap: :clap: :clap:

:xm:
Author:  TraderJoeForex [ Sun Sep 10, 2017 3:02 pm ]
Post subject:  Awesome - original version

Thanks Steve and Thomas :smile:
Author:  SteveHopwood [ Sun Sep 10, 2017 5:53 pm ]
Post subject:  Awesome - original version

Here is another PM I just received from Thomas:
tomele wrote:Hi Steve.

Oh my god, those skinners really think in pixels ...

I made some minor optimizations for larger font sizes in the "void Display()" code. Mainly the line distances are calculated better (line 17). If you think the line spacing ist too wide, you can use a factor of 1.4 or less here. The parameters in line 30+32 are perfect for larger font sizes and even other fonts now. If you want to, just replace the code in your post with this one:

Code: Select all

void Display(string text)
{
  string lab_str = "OAM-" + IntegerToString(DisplayCount);  
  double ofset = 0;
  string textpart[5];
  uint w,h;
  
  for (int cc = 0; cc < 5; cc++)
  {
     textpart[cc] = StringSubstr(text,cc*63,64);
     if (StringLen(textpart[cc]) ==0) continue;
     lab_str = lab_str + IntegerToString(cc);
    
     ObjectCreate(lab_str, OBJ_LABEL, 0, 0, 0);
     ObjectSet(lab_str, OBJPROP_CORNER, 0);
     ObjectSet(lab_str, OBJPROP_XDISTANCE, DisplayX + ofset);
     ObjectSet(lab_str, OBJPROP_YDISTANCE, DisplayY+DisplayCount*(int)(fontSise*1.5));
     ObjectSet(lab_str, OBJPROP_BACK, false);
     ObjectSetText(lab_str, textpart[cc], fontSise, fontName, colour);
    
     /////////////////////////////////////////////////
     //Calculate label size
     //Tomele supplied this code to eliminate the gaps in the text.
     //Thanks Thomas.
     TextSetFont(fontName,-fontSise*10,0,0);
     TextGetSize(textpart[cc],w,h);
    
     //Trim trailing space
     if (StringSubstr(textpart[cc],63,1)==" ")
        ofset+=(int)(w-fontSise*0.3);
     else
        ofset+=(int)(w-fontSise*0.7);
     /////////////////////////////////////////////////
        
  }//for (int cc = 0; cc < 5; cc++)
}
Nice, isnt it?



Cheers, Thomas
I have not made the extra changes to Awesome, so copy the code here over the existing function if you want the latest improvements.

Thanks Thomas. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

:xm:
Author:  DigitalCrypto [ Sun Sep 10, 2017 9:00 pm ]
Post subject:  Awesome - original version

Brilliant gentlemen. Huge Thank you! :D
Author:  DigitalCrypto [ Mon Sep 11, 2017 12:02 am ]
Post subject:  Awesome - original version

Hey Steve,

I would like to add "Todays P&L" to the left of "Daily Profit Target" on the screen display.

I see around line 1577 of CountOpenTrades() the "EntirePositionCashUpl" var. Would this be the similar in function to your shell's "OverallProfit" variable?

Thanks,
David

EDIT: This is the change I made

Code: Select all

   //Profit targets
   text = "";
   
   if (!CloseEnough(EntirePositionCashUpl, 0) )
      text = "Today's P&L = " + DoubleToStr(EntirePositionCashUpl, 2) + "    ";

   if (!CloseEnough(DailyProfitTarget, 0) )
      text = text + "Daily profit target = " + DoubleToStr(DailyProfitTarget, 2) + "    ";
   if (!CloseEnough(WeeklyProfitTarget, 0) )
      text = text + "Weekly profit target = " + DoubleToStr(WeeklyProfitTarget, 2);
Author:  SteveHopwood [ Mon Sep 11, 2017 10:47 am ]
Post subject:  Awesome - original version

DigitalCrypto » Mon Sep 11, 2017 12:02 am wrote:Hey Steve,

I would like to add "Todays P&L" to the left of "Daily Profit Target" on the screen display.

I see around line 1577 of CountOpenTrades() the "EntirePositionCashUpl" var. Would this be the similar in function to your shell's "OverallProfit" variable?

Thanks,
David

EDIT: This is the change I made
No, it isn't but this is a good idea so I have added it to V 1j in post 1 - also Thomas' improvement to his improvements to the chart display code.

Yours called for a new variable, so do a search for "ProfitToday" to follow the code I added.

:xm:
Author:  DigitalCrypto [ Mon Sep 11, 2017 11:33 am ]
Post subject:  Awesome - original version

Many thanks Steve,

I was a bit lost on how to go about that. I did have to make a small change in 1j in the DisplayUserFeedback to get the text variable to append.

Code: Select all

text = "Daily profit target = " + DoubleToStr(DailyProfitTarget, 2) + "    ";
Changed to

Code: Select all

text = text + "Daily profit target = " + DoubleToStr(DailyProfitTarget, 2) + "    ";
Works perfectly! :clap:
Author:  SteveHopwood [ Mon Sep 11, 2017 11:44 am ]
Post subject:  Awesome - original version

DigitalCrypto » Mon Sep 11, 2017 11:33 am wrote:Many thanks Steve,

I was a bit lost on how to go about that. I did have to make a small change in 1j in the DisplayUserFeedback to get the text variable to append.

Code: Select all

text = "Daily profit target = " + DoubleToStr(DailyProfitTarget, 2) + "    ";
Changed to

Code: Select all

text = text + "Daily profit target = " + DoubleToStr(DailyProfitTarget, 2) + "    ";
Works perfectly! :clap:
I forgot to add that bit. I have added it to 1j in post 1.

:xm:
Author:  SteveHopwood [ Mon Sep 11, 2017 12:47 pm ]
Post subject:  Awesome - original version

V 1k is in post 1, courtesy of Thomas again. Just look at what he has done with the chart display:
XAUUSDH4.png
Brilliant Thomas. Absolutely brilliant. :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

:xm:
Author:  DigitalCrypto [ Mon Sep 11, 2017 5:48 pm ]
Post subject:  Awesome - original version

Damn fine job there Steve and Tomele

Now that you've gone and made a display that "purty" it begs for a feature request for even better. I don't suppose you could make the symbol name clickable to open that particular chart could you?

I recall seeing "Dashboard Trading" thread on that other site that had some source code you could probably get some ideas from.
All times are UTC Page 29 of 46