PDA

View Full Version : convert the code into vtl



AmitSharma
01-30-2014, 04:12 PM
for(i = 10; i >= 0; i--)
{
double fasterMAnow = iMA(NULL, 0, FasterMA, 0, MA1_Type,
PRICE_CLOSE, i);
double fasterMAprevious = iMA(NULL, 0, FasterMA, 0, MA1_Type,
PRICE_CLOSE, i + 1);
double fasterMAafter = iMA(NULL, 0, FasterMA, 0, MA1_Type,
PRICE_CLOSE, i - 1);
double slowerMAnow = iMA(NULL, 0, SlowerMA, 0, MA2_Type,
PRICE_CLOSE, i);
double slowerMAprevious = iMA(NULL, 0, SlowerMA, 0,
MA2_Type, PRICE_CLOSE, i + 1);
double slowerMAafter = iMA(NULL, 0, SlowerMA, 0, MA2_Type,
PRICE_CLOSE, i - 1);

double MACD = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow,
MACD_Signal, PRICE_CLOSE, MODE_MAIN, i);
double MACD_Sig = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow,
MACD_Signal, PRICE_CLOSE, MODE_SIGNAL, i);

double ADX1 = iADX(NULL, 0, ADX, PRICE_CLOSE, MODE_PLUSDI, i);
double ADX2 = iADX(NULL, 0, ADX, PRICE_CLOSE, MODE_MINUSDI, i);

double RSIV = iRSI(NULL, 0, RSI, 0, i);
double DEM = iDeMarker(NULL, 0, DeMarker, i);
double MOM = iMomentum( NULL,0, Momentum, PRICE_CLOSE, i);
double FI = iForce(NULL, 0, ForceIndex, 1, PRICE_CLOSE, i);
if(MOM > 100)
Up[i] = 0.05;
if(MOM <= 100)
Down[i] = 0.05;
if(DEM > 0.5 && FI >0)
TrendUp[i] = 0.22;
if(DEM < 0.5 < 50 && FI < 0)
TrendDown[i] = 0.22;
if(RSIV > 50 && MACD > MACD_Sig && ADX1 > ADX2)
CrossUp[i] = 0.47;
if(RSIV < 50 && MACD < MACD_Sig && ADX1 < ADX2)
CrossDown[i] = 0.47;
if((fasterMAnow > slowerMAnow) &&
(fasterMAprevious < slowerMAprevious) &&
(fasterMAafter > slowerMAafter))
{
MAUp[i] = 0.8;
if(SoundAlert == true)
{
Alert("("Profit " + Symbol() + " on the " +
Period() + " minute chart.");
}
}
if((fasterMAnow < (slowerMAnow)) &&
(fasterMAprevious > (slowerMAprevious)) &&
(fasterMAafter < slowerMAafter))
{
MADown[i] = 0.8;
if(SoundAlert == true)
Alert("Profit " + Symbol() + " on the " +
Period() + " minute chart.");
}

}

Hassan-HS
01-30-2014, 07:36 PM
Hello amit,


please be more specific, show me where you are face difficulties and i will help you...

AmitSharma
01-31-2014, 03:17 PM
Hi Sir,

Please convert below line into vtl?

double RSIV = iRSI(NULL, 0, RSI, 0, i);
double DEM = iDeMarker(NULL, 0, DeMarker, i);
double MOM = iMomentum( NULL,0, Momentum, PRICE_CLOSE, i);
double FI = iForce(NULL, 0, ForceIndex, 1, PRICE_CLOSE, i);

Let me know if you have suggestion..

How to show alert in vtl?


Thank you

Hassan-HS
02-01-2014, 08:23 AM
Hello Amit,


double RSIV = iRSI(NULL, 0, RSI, 0, i);


you can add iRSI indicator to a specific chart using RelativeStrengthIndex (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1778), and to get any value use ObjectSeriesGetValue (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2664)


Public Sub main()
Dim IndKey
Dim value
IndKey = RelativestrengthIndex (0,PRICE_CLOSE,10,3)
ObjectSeriesGetValue 0, CSTR(IndKey), CLNG(bars(0)), value
msgbox value
End Sub






This indicators are not included in built in TASDK functions, you have to do its calculation manually using its formula after that you can attach the result using AddCustomIndicator (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2662).


[QUOTE]double MOM = iMomentum( NULL,0, Momentum, PRICE_CLOSE, i);


please check the following article LinearMomentumOscillatorOnArray (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3475)




How to show alert in vtl?

you can add a label on the chart in this way...




Dim objText

Dim objID

Dim fontSize

Dim XPos

Dim YPos

Public Sub main()

fontSize = 15

objColor = RGBColor(50,50,100)

If AccountInfoInteger(ACCOUNT_LOGIN) = -1 Then ' Check if account is selected

MsgBox "Please select an account first"

Else

objID = "lblText" ' ID of the label object

XPos = 10 ' X position on chart

YPos = 25 ' Y position on chart

objText="Text goes here." ' Sets the text of the label.

CreateObjectLabel 0,0,CSTR(objID),CINT(XPos),CINT(YPos),objText 'Creates the label with the selected parameters

ObjectSetText 0, CSTR(objID),CINT(fontSize),,CLNG(objColor) ' Sets the label properties.

End If

End Sub