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

Board TechNews
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3318
Page 9 of 19
Author:  milanese [ Mon Jan 27, 2014 2:43 pm ]
Post subject:  better showing mql code in code box

Hello :hi:

I am working on a better code visualyzing for mql code here this is now in an early alpha state but if you use the code tag with code=mql (just use the quote here, if you don't get it, to see how) the mql code is better readable..

Exp.:

Code: Select all

if(OrderType() == OP_BUY) //we have a buy order
		{   
		ticket=OrderTicket();
		  
			{
			   
				NewSL=NormalizeDouble(ExtMapBuffer6[1]-(HA_SLMovingDistance*Point), Digits);
			   
				if((Bid-NewSL)>(HA_SLMovingDistance*Point))
				if((Bid-NewSL)>(SetBEminPip*Point))
				{
				if((NormalizeDouble(OrderStopLoss(), Digits) != NormalizeDouble(NewSL, Digits)))
					if(		 ((NewSL>OrderStopLoss())||(OrderStopLoss()<(1*Point))) &&   (NewSL!=0) && (NewSL < Bid - (10*multiplier*Point))   )
					{
					
						Alert("SetBEAndJump :Attempting to move SL of ",symbol," to ",NewSL);
						Print("SetBEAndJump :Attempting to move SL of ",symbol," to ",NewSL);
						ModifyOrder(ticket,NewSL,0);
					}
				}
			}		   
Cheers :)

Tommaso
Author:  dudest [ Mon Jan 27, 2014 3:43 pm ]
Post subject:  Re: Board TechNews

Great work mate!! Looking good :)

Cheers!
Author:  SteveHopwood [ Mon Jan 27, 2014 5:38 pm ]
Post subject:  Re: Board TechNews

Fabulous Tommaso. Thanks.

:D
Author:  milanese [ Tue Jan 28, 2014 3:21 pm ]
Post subject:  Re: better showing mql code in code box

milanese » Mon Jan 27, 2014 2:43 pm wrote:Hello :hi:

I am working on a better code visualyzing for mql code here this is now in an early alpha state but if you use the code tag with code=mql (just use the quote here, if you don't get it, to see how) the mql code is better readable..

Exp.:

Code: Select all

if(OrderType() == OP_BUY) //we have a buy order
		{   
		ticket=OrderTicket();
		  
			{
			   
				NewSL=NormalizeDouble(ExtMapBuffer6[1]-(HA_SLMovingDistance*Point), Digits);
			   
				if((Bid-NewSL)>(HA_SLMovingDistance*Point))
				if((Bid-NewSL)>(SetBEminPip*Point))
				{
				if((NormalizeDouble(OrderStopLoss(), Digits) != NormalizeDouble(NewSL, Digits)))
					if(		 ((NewSL>OrderStopLoss())||(OrderStopLoss()<(1*Point))) &&   (NewSL!=0) && (NewSL < Bid - (10*multiplier*Point))   )
					{
					
						Alert("SetBEAndJump :Attempting to move SL of ",symbol," to ",NewSL);
						Print("SetBEAndJump :Attempting to move SL of ",symbol," to ",NewSL);
						ModifyOrder(ticket,NewSL,0);
					}
				}
			}		   
Cheers :)

Tommaso
Now this feature is standart for the codebox it works without using code=mql...

Code: Select all

bool CheckTradeAllowedMargin()//we must check margin before opening a trade
{ bool allowed=true;
	if(IsTesting()==false)
	{
		if((MarketInfo(Symbol(),MODE_MARGINREQUIRED)*lot)>=(AccountFreeMargin()/2))allowed=false;
		if(AccountMargin()>0)
		{
			double freemarginpercentile=(AccountEquity()/AccountMargin())*100;
			if(freemarginpercentile<RequiredMarginPercentile)allowed=false;
		}  
   }
	return(allowed);
} 
note this will only work in new posts, old posts are not changed..
Cheers :)

Tommaso
Author:  fxozgirl [ Wed Jan 29, 2014 4:21 am ]
Post subject:  Re: Board TechNews

Hi Tomasso, your work on the forum is outstanding...thanks for all your efforts :clap:
Author:  milanese [ Wed Jan 29, 2014 4:48 pm ]
Post subject:  Re: better showing mql code in code box

Hello ,

as I told the new codebox is a project in development now you find a new version, but unfortunately you must use code=mql in the fist [] (do hit the quote button of this post if you don't understand how), this about our old post using code, they work only so and reparsing of all old posts would be to much work..
The new code box highlightes mql syntax, this not complett at the moment but I am working to add the complett mql4 syntax so the code is again much better readable

Cheers :)

Tommaso

Code: Select all

int start()
  {
   int i, counted_bars = IndicatorCounted();
   if(counted_bars< 0) 
      return(-1);
   if(counted_bars> 0) 
      counted_bars--;
   int limit = Bars - 1 - counted_bars; 
   
   for(i=limit; i>=0; i--)
   {
      curDate = stripToDate_(Time[i]); 
      int g = 0;
      while(g<Qty){
         Session_(saName, curDate, lastDate, t1, t2, lo, hi, pip, col[g], g, i); 
         g++;
      }
   }  
   return(0);
  }
Author:  milanese [ Wed Jan 29, 2014 10:43 pm ]
Post subject:  Re: Board TechNews

Using code=cpp the new code box will highlight too c++ code if needed ;)

exp:

Code: Select all

// crappy.cpp
#include <iostream>
using namespace std;
#include "SimpleH.h"

namespace nmspace
{
 void myclass::Crap()
 {
  cout << "I'm called within a crappy DLL!";
 }
}
Cheers :)

Tommaso
Author:  dudest [ Wed Jan 29, 2014 10:52 pm ]
Post subject:  Re: Board TechNews

You are a machine my friend!, good stuff! :)
Author:  milanese [ Wed Jan 29, 2014 10:56 pm ]
Post subject:  Re: Board TechNews

dudest » Wed Jan 29, 2014 10:52 pm wrote:You are a machine my friend!, good stuff! :)
Thank you mate! I think with all the crap changes that are coming we will have more need for the codebox than ever before...

Cheers :)

Tommaso
Author:  milanese [ Thu Jan 30, 2014 1:59 pm ]
Post subject:  Re: Board TechNews

Hi all,
now I got it :smile:
Now the code box makes as standart, without using "=mql" after the code tag syntax highlight for mql4 code, now you can use it with all comfort :)
Near all mq4 syntax is embedded now...
Enjoy posting your code in the new code box.

Cheers :)
Tommaso

Code: Select all

extern color ExtColor=LightSeaGreen;

string ExtName="Exposure";
string ExtSymbols[SYMBOLS_MAX];
int    ExtSymbolsTotal=0;
double ExtSymbolsSummaries[SYMBOLS_MAX][7];
int    ExtLines=-1;
string ExtCols[8]={"Symbol",
                   "Deals",
                   "Buy lots",
                   "Buy price",
                   "Sell lots",
                   "Sell price",
                   "Net lots",
                   "Profit"};
int    ExtShifts[8]={ 10, 80, 130, 180, 260, 310, 390, 460 };
int    ExtVertShift=14;
double ExtMapBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init()
  {
	IndicatorShortName(ExtName);
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexStyle(0,DRAW_NONE);
   IndicatorDigits(0);
	SetIndexEmptyValue(0,0.0);
  }
All times are UTC Page 9 of 19