Can't get Indicator pivot points to match on EA code - mql4

I've been messing around with the Camarilla Indicator and I wanted to get the main pivot values for my EA, can I use iCustom() for that? or should I just pass the code to the EA? but where exactly would I place it? I tried to place it on the onTick() but with a condition of only calculating the pivots when there is a new daily candle, but the values most of the times don't match.
void OnTick()
{
static datetime today;
if (today != iTime (Symbol(), PERIOD_D1, 0))
{
today = iTime (Symbol(), PERIOD_D1, 0);
int counted_bars=IndicatorCounted();
//---- TODO: add your code here
int cnt=720;
//---- exit if period is greater than daily charts
if(Period() > 1440)
{
Print("Error - Chart period is greater than 1 day.");
}
//---- Get new daily prices & calculate pivots
day_high=0;
day_low=0;
yesterday_open=0;
today_open=0;
cur_day=0;
prev_day=0;
while (cnt!= 0)
{
if (TimeDayOfWeek(Time[cnt]) == 0)
{
cur_day = prev_day;
}
else
{
cur_day = TimeDay(Time[cnt]- (GMTshift*3600));
}
if (prev_day != cur_day)
{
yesterday_close = Close[cnt+1];
today_open = Open[cnt];
yesterday_high = day_high;
yesterday_low = day_low;
day_high = High[cnt];
day_low = Low[cnt];
prev_day = cur_day;
}
if (High[cnt]>day_high)
{
day_high = High[cnt];
}
if (Low[cnt]<day_low)
{
day_low = Low[cnt];
}
cnt--;
}
H3 = ((yesterday_high - yesterday_low)* D3) + yesterday_close;
H4 = ((yesterday_high - yesterday_low)* D4) + yesterday_close;
L3 = yesterday_close - ((yesterday_high - yesterday_low)*(D3));
L4 = yesterday_close - ((yesterday_high - yesterday_low)*(D4));
L5 = yesterday_close - (H5 - yesterday_close);
H5 = (yesterday_high/yesterday_low)*yesterday_close;
Print ("H3: " + DoubleToStr(H3));
Print ("H4: " + DoubleToStr(H4));
Print ("H5: " + DoubleToStr(H5));
Print ("L3: " + DoubleToStr(L3));
Print ("L4: " + DoubleToStr(L4));
Print ("L5: " + DoubleToStr(L5));
}

Related

Why Buy order is not placed when calculated Stoploss and Take profit are used

I have a simple BUY order that, when the Take Profit and Stoploss are in points (ie: Ask+10*_Point), operates correctly. But when I change the take profit and stop loss from points to my own calculated values (CL_OP), the BUY order is not placing trades. How can I solve the issue:
input int _Hour =16;
input int _Minute =30;
bool NewBar()
{
static datetime OldTime = 0;
if(OldTime < Time[0])
{
OldTime = Time[0];
return(true);
}
else
{
return(false);
}
}
void OnTick()
{
int Hour_Int = Hour();
int Minute_Int = Minute();
double CL_OP = (Close[1] - Open[1]);
bool LastBearHiLoEngulf = (Close[1] < Open[1] && High[1] > High[2] && Low[1] < Low[2] );
if(NewBar())
if(OrdersTotal()==0)
// Apply signals on Buy opportunities
if( Hour_Int == _Hour && Minute_Int == _Minute && LastBearHiLoEngulf == TRUE)
{
int buyticket = OrderSend
(
Symbol(), // all symbols
OP_BUY, // Buy without delay
1, // 1 Microlots
Ask, // for market price
3, // 3 pips slippage
Ask - CL_OP, // Stop Loss - 1000*_Point
Ask + CL_OP , // Take profitworks with 100*_Point
"Buy LastBearHiLoEngulf Target: ", // comment
144, // Magic number
0, // no experiation day
Green // draw green arrow
);
}
}
double CL_OP = (Close[1] - Open[1]);
CL_OP is not a normal price to open trade. Actually, it is the Size of the Candle 1!
It should be something like this:
double CL_OP = Close[1] + (Close[1] - Open[1]);

Only One EA works at a time. The others won't open as long as there's a trade

The Orderselect is used to control the number of trades the EA opens. I didnt use OrdersTotal because it creates the problem of blocking other EAs. Now it seems OrdersSelect also does the same thing. I need each EA to only open two trades and allow other EAs to open theirs too.
void OnTick()
{
double movingAverageSS = iMA(NULL,60,LowerMAS,0,MODE_SMA,PRICE_CLOSE,0);
double lastmovingAverageSS = iMA(NULL,60,LowerMAS,0,MODE_SMA,PRICE_CLOSE,1);
double movingAverageSB = iMA(NULL,60,LowerMAB,0,MODE_SMA,PRICE_CLOSE,0);
double lastmovingAverageSB = iMA(NULL,60,LowerMAB,0,MODE_SMA,PRICE_CLOSE,1);
double movingAverageFS = iMA(NULL,60,UpperMAS,0,MODE_SMA,PRICE_CLOSE,0);
double lastmovingAverageFS = iMA(NULL,60,UpperMAS,0,MODE_SMA,PRICE_CLOSE,1);
double movingAverageFB = iMA(NULL,60,UpperMAB,0,MODE_SMA,PRICE_CLOSE,0);
double lastmovingAverageFB = iMA(NULL,60,UpperMAB,0,MODE_SMA,PRICE_CLOSE,1);
for(int b=0;b<OrdersTotal();b++)
{
if (OrderSelect(b,SELECT_BY_POS,MODE_TRADES) == true)
{
if (OrderMagicNumber() != MagicB)
{
if((lastmovingAverageFB<lastmovingAverageSB) && (movingAverageFB > movingAverageSB))
{
b = OrderSend (Symbol(),OP_BUY,lotSize,Ask,4,Ask - SLPB*_Point, Ask + TPB1*_Point,NULL,128,0,Green);
b = OrderSend (Symbol(),OP_BUY,lotSize,Ask,4,Ask - SLPB*_Point, Ask + TPB2*_Point,NULL,128,0,Green);
}
else if((lastmovingAverageFS>lastmovingAverageSS)&&(movingAverageFS<movingAverageSS))
{
b = OrderSend (Symbol(),OP_SELL,lotSize,Bid,4,Ask + SLPS*_Point,Ask - TPS1*_Point,NULL,128,0,Red);
b = OrderSend (Symbol(),OP_SELL,lotSize,Bid,4,Ask + SLPS*_Point,Ask - TPS2*_Point,NULL,128,0,Red);
}
}
}
}

How to access the baseline comparison results in IBM Rational Doors from scripts?

The background to the question is, that I would like to create software change requests from Doors requirement changes.
For this I have to get the differences of requirements between two user selectable baselines of a module in a human readable format.
In the GUI I use the "Baseline Compare" function.
How can I access these results from a script (inside or outside of Doors) in a structured format?
A good starting point might the Doors DXL library Tools -> DXL Library -> baseline comparator example, but it needs heavy modifications for your overall use-case I guess. Take a look.
Found a modified version of the baseline compare script at this forum . I haven't tried it yet, but here's the code, which does use a GUI but you should be able to redirect the input & output pretty easily:
// Your Company Baseline Compare with Attributes
/*
Date Posted: 16-Jan-2008 00:03
Posted By: Juergen Albrecht
*/
/*
// (Your Company Baseline Compare) *
//---------------------------------------------------------------------------*
// *
// Project: Your Company Ottobrunn *
// *
//---------------------------------------------------------------------------*
// Module: all modules for baseline compare *
//---------------------------------------------------------------------------*
// Description: ... *
// *
// Functions: compare any two baselines of the current module *
// (or a baseline against the current version). *
// Sets a filter on objects which differ with request *
// to Object Heading, Object Text, Object Type and .... *
// *
// *
// Copyright (C) Your Company Your Town 2005-2007 Confidential. All rights reserved. *
//---------------------------------------------------------------------------*
// *
// $Header: /doors/lib/dxl/addins/user/BaselineCompare.dxl Ver. 1.0 15.03.06 18:00 UID-USER $
// *
//---------------------------------------------------------------------------*
// $History: BaselineCompare.dxl $
//
//********************************* Version 1.0 ****************************
// User: Date: Time: *
// Jürgen Albrecht (uid-al28423) 15.01.08 18:00
// Created in $/doors/lib/dxl/addins/user/BaselineCompare.dxl
//---------------------------------------------------------------------------*
// *
// *
// *
//---------------------------------------------------------------------------*
*/
pragma runLim, 0
////////////////////////////////////////////////////// constants for Attributes
const string DUMMY_LIST[] = {}
const string strAffectsArr[] = {"Ch.Bars", "Ch.Date", "History"}
const string strCharacterArr[] = {"System ", "Hidden ", "Customised"}
const string strValidityArr[] = {"Module ", "Object"}
const string strPropertyArr[] = {"Inherited", "Multi value"}
////////////////////////////////////////////////////// variables for Attributes
DB dbBLCompare = null
DBE dbeAttrDefNameList = null
DBE dbeAttrCharacter = null
DBE dbeAttrAffects = null
DBE dbeAttrValidity = null
DBE dbeAttrProperty = null
DBE dbeAttrType = null
DBE dbeDefaultValue = null
DBE dbeAttrTypeList = null
DBE dbeAttrTypeSelect = null
////////////////////////////////////////////////////// functions for Attributes
int chopInsert2(DBE inlist, string s)
{ int no_inlist = noElems inlist
int low = 0
int high = no_inlist-1
int hw = 0
string c
if (no_inlist == 0)
{ insert(inlist,0,s)
setCheck(inlist,0,false)
return 0
}
while (high-low > 1)
{ hw = low + ((high-low) / 2)
c = get(inlist,hw)
if (s < c)
high = hw
else
low = hw
}
c = get(inlist,high)
if (c < s)
{ insert(inlist,high+1,s)
setCheck(inlist,high+1,false)
return high + 1
}
c = get(inlist,low)
if (c > s)
{ insert(inlist,low,s)
setCheck(inlist,low,false)
return low
}
insert(inlist,low+1,s)
setCheck(inlist,low+1,false)
return low+1
} // chopInsert2
void populateLstAttrDef(bool bIncludeSystemAttr)
{ AttrDef ad
for ad in current Module do
{ if (ad.module)
continue
if (!bIncludeSystemAttr)
{ if (ad.system || ad.hidden)
continue
}
chopInsert2(dbeAttrDefNameList, ad.name "")
}
set(dbeAttrDefNameList, 0, true)
} // populateLstAttrDef
void doNothing(DBE dbeKlick, int iKlick)
{
} // doNothing
void cbSystemSelect(DBE dbeKlick)
{ bool bSelect = get(dbeAttrTypeSelect)
empty (dbeAttrDefNameList)
populateLstAttrDef (bSelect)
} // cbSystemSelect
void doSetAttrTypes(void)
{
AttrDef ad = find(current Module, get(dbeAttrDefNameList, get(dbeAttrDefNameList)))
AttrType at = find(current Module, ad.typeName "")
string strDefVal = "", strAttrType = "", s = ""
int iAttrChar = 0, iAttrValid = 0, iProperty = 0, iAffects = 0
if (ad.system)
iAttrChar = 1
else
iAttrChar = 4
if (ad.hidden)
iAttrChar = iAttrChar | 2
set(dbeAttrCharacter, iAttrChar)
if (ad.object)
iAttrValid = 2
if (ad.module)
iAttrValid = iAttrValid | 1
set(dbeAttrValidity, iAttrValid)
if (ad.inherit)
iProperty = 1
if (ad.multi)
iProperty = iProperty | 2
set(dbeAttrProperty, iProperty)
if (!ad.nobars)
iAffects = 1
if (!ad.nochanges)
iAffects = iAffects | 2
if (!ad.nohistory)
iAffects = iAffects | 4
set(dbeAttrAffects, iAffects)
if ( null at )
{ strAttrType = "Unable to determine type of attribute"
set(dbeAttrType, strAttrType)
return
}
strAttrType = at.type ""
if ( at.type == attrInteger )
{ int i
if ( at.minValue )
{ i = at.minValue
s = s "Min > " i "\n"
}
if ( at.maxValue )
{ i = at.maxValue
s = s "Max < " i "\n"
}
}
else if ( at.type == attrReal )
{ real r
if ( at.minValue )
{ r = at.minValue
s = s "Min > " r "\n"
}
if ( at.maxValue )
{ r = at.maxValue
s = s "Max < " r "\n"
}
}
else if ( at.type == attrDate )
{ Date d
if ( at.minValue )
{ d = at.minValue
s = s "Min > " d "\n"
}
if ( at.maxValue )
{ d = at.maxValue
s = s "Max < " d "\n"
}
}
else if ( at.type == attrEnumeration )
{ string strAttrTypeName = at.name
strAttrType = strAttrType ": " strAttrTypeName
int i
for ( i = 0; i < at.size; ++i )
s = s at.strings[i] "\n"
}
set(dbeAttrType, strAttrType)
set(dbeAttrTypeList, s)
if (ad.defval)
{ if (strDefVal == "")
strDefVal = ad.defval
set (dbeDefaultValue, strDefVal)
}
else
set (dbeDefaultValue, "")
// Ausgabe in File
// output << ad.name"\n"
// output << s"\n"
} // doSetAttrTypes
void cbDoSetAttrTypes(DBE dbeKlick, int iKlick)
{ doSetAttrTypes
} // cbDoSetAttrTypes
void showAttributes()
{ if ( null current Module )
{ ack "This tool must be run within a module..."
halt
}
// Ausgabe in File
// output << "\t\t"(current Module)."Name""\n"
populateLstAttrDef(true)
doSetAttrTypes()
// close output
} // showAttrInvestigatorDB
/////////////////////////////////////////// Definition for Modules
DBE lblOldList, lblNewList
DBE dbeListCurrent, dbeListBaseline // two global lists containing the baseline selected (or current version)
DBE dbeOutFileBrowse, dbeOutFileLabel
DBE dbeChangeBarToggle
DBE dbeShowDiffToggle
Stream outFile
Skip skBaselines = create // cache current baselines
bool bShowDiff
string strCellBorders = "\\clbrdrt\\brdrs\\brdrw15\\brdrcf11 \\clbrdrl\\brdrs\\brdrw15\\brdrcf11 \\clbrdrb\\brdrs\\brdrw15\\brdrcf11 \\clbrdrr\\brdrs\\brdrw15\\brdrcf11 "
string lastHeadingNumber(Object o)
{ Regexp reg = regexp "\\.0-[0-9]+$"
string onum = number o
if (onum[0:0] == "0")
{ return "0"
}
else if (reg onum)
{ int i = start 0
string hd = onum[0:i-1]
while (reg hd)
{ int j = start 0
hd = hd[0:j-1]
}
return hd
}
else
{ return onum
}
} // lastHeadingNumber
bool oleInsDel(Object o1,o2)
{ bool oleRec = false
string modType = ""
int oldOle = oleCount(o2."Object Text")
int newOle = oleCount(o1."Object Text")
if (newOle > oldOle)
{ oleRec = true
modType = "Figure/Table inserted"
}
if (newOle < oldOle)
{ oleRec = true
modType = "Figure/Table deleted"
}
if (oleRec)
{ outFile << "\\trowd \\trgaph108\\trleft-108\\trkeep"
outFile << strCellBorders "\\cellx1026 " strCellBorders "\\cellx2727 " strCellBorders "\\cellx6129 " strCellBorders "\\cellx9531\n"
outFile << "\\intbl " identifier(o1) " section " lastHeadingNumber(o1) "\\cell OLE\\cell " modType "\\cell \\cell\\row\n"
}
return oleRec
} // oleInsDel
bool oleChange(Object o1,o2)
{ int i = oleCount o1."Object Text"
if (i > 0)
{ Buffer b1 = create
Buffer b2 = create
b1 = richTextWithOle o1."Object Text"
b2 = richTextWithOle o2."Object Text"
int l1 = length b1
int l2 = length b2
delete b1
delete b2
if (l1 != l2)
{ outFile << "\\trowd \\trgaph108\\trleft-108\\trkeep"
outFile << strCellBorders "\\cellx1026 " strCellBorders "\\cellx2727 " strCellBorders "\\cellx6129 " strCellBorders "\\cellx9531\n"
outFile << "\\intbl " identifier(o1) " section " lastHeadingNumber(o1) "\\cell OLE\\cell Figure/Table modified\\cell \\cell\\row\n"
accept o1 // set filter
accept o2 // on both objects
return true
}
}
return false
} // oleChange
bool compareObjects(int absno, Object o1, o2, string attr)
{ // function to compare an attribute of two objects with same absolute number
Buffer s1 = create
Buffer s2 = create
Buffer s3 = create
s1 = o1.attr
s2 = o2.attr
if (s1!=s2)
{ outFile << "\\trowd \\trgaph108\\trleft-108\\trkeep"
// if ((attr=="Object Text") && bShowDiff)
if (bShowDiff)
// {
// diff(s3, s2, s1,"\\cf1\\strike ","\\cf3\\ul ")
// outFile << strCellBorders "\\cellx1026 " strCellBorders "\\cellx2727 " strCellBorders "\\cellx9531\n"
// outFile << "\\intbl \\fs16 " identifier(o1) " section " lastHeadingNumber(o1) "\\cell " attr "\\cell " s3 "\\cell " s2 "\\cell\\row\n"
// }
{ diff(s3, s2, s1)
Regexp ct = regexp "colortbl[^}]*}"
string frag
if (ct s3)
{ frag = s3[end 0 + 1:(length s3) - 3]
}
else
{ frag = richTextFragment stringOf(s3)
}
outFile << strCellBorders "\\cellx1026 " strCellBorders "\\cellx2727 " strCellBorders "\\cellx9531\n"
outFile << "\\intbl \\fs16 " identifier(o1) " section " lastHeadingNumber(o1) "\\cell " attr "\\cell " frag "\\cell\\row\n"
}
else
{ outFile << strCellBorders "\\cellx1026 " strCellBorders "\\cellx2727 " strCellBorders "\\cellx6129 " strCellBorders "\\cellx9531\n"
outFile << "\\intbl \\fs16 " identifier(o1) " section " lastHeadingNumber(o1) "\\cell " attr "\\cell " s1 "\\cell " s2 "\\cell\\row\n"
}
accept o1 // set filter
accept o2 // on both objects
delete s1
delete s2
delete s3
return false
}
delete s1
delete s2
delete s3
return true
} // compareObjects
Skip getAbsnos(Module m)
{ // Build a skip list which maps absnos onto their corresponding objects. Also initialize the DXL filter to "reject"
Skip res = create
Object o
for o in m do
{ int a = o."Absolute Number"
reject o // filter those mentioned in report
put(res, a, o)
}
return res
} // getAbsnos
void applyCompareFunction (DB dbKlick)
{ // Main comparison routine: find out which modules to compare
// compare objects present in both, report on
// those present in only one.
string name1, name2, outf
int idx1, idx2
bool updateChangeBars
idx1 = get dbeListCurrent // position in list
idx2 = get dbeListBaseline
name1 = get dbeListCurrent // baseline name
name2 = get dbeListBaseline
outf = get dbeOutFileBrowse
updateChangeBars = get dbeChangeBarToggle
bShowDiff = get dbeShowDiffToggle
if (idx1 < 0 || idx2 < 0) // error checking
{ ack "two selections are needed"
return
}
else if (idx1 == idx2)
{ ack "same selection on both sides"
return
}
Regexp slash = regexp "[\\\\]"
if (!slash outf)
{ outf = currentDirectory "\\" outf
}
Baseline sel1, sel2
outFile = write outf
outFile << "{\\rtf1\\deff0{\\fonttbl{\\f0\\fswiss\\fcharset177 Times New Roman;}}{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;}\n"
outFile << "\\paperw11906\\paperh16838\\margl1134\\margr567\\margt1134\\margb851\\headery567\\footery567\n"
string where = (current Module)."Name"
outFile << "\\ul \\fs24 Modified Objects in Module: " where "\\ul0 \\par \\par\n"
outFile << "\\trowd \\trgaph108\\trleft-108\\trhdr"
outFile << strCellBorders "\\cellx1026 " strCellBorders "\\cellx2727 " strCellBorders "\\cellx6129 " strCellBorders "\\cellx9531\n"
outFile << "\\intbl \\fs20 Identifier\\cell Attribute\\cell Current Baseline\\cell Old Baseline\\cell\\row\n"
string str
for str in skBaselines do // find each baseline
{ Baseline b = key skBaselines // the baseline is the key
string str = (major b) "." (minor b) (suffix b)
if (name1==str) sel1 = b
if (name2==str) sel2 = b
}
progressStart(dbBLCompare, "Baseline Compare", "", 1)
Module old = current
Module b1, b2
if (idx1==0)
b1 = old // i.e. the current Module
else
{ progressMessage("Load First Baseline Module")
b1 = load(sel1, true) // load the baselines on the screen
}
progressStop()
progressStart(dbBLCompare, "Baseline Compare", "", 1)
if (idx2==0)
b2 = old // i.e.e the current Module
else
{ progressMessage("Load Second Baseline Module")
b2 = load(sel2, true)
}
progressStop()
if (updateChangeBars and (idx1 == 0))
{ AttrDef atcb
atcb = find(b1,"ChangeBar")
if (null atcb)
{ updateChangeBars = false
ack "No ChangeBar attribute in current module"
}
else
{ atcb = find(b1,"WordDocChangeLog")
if (!null atcb)
{ b1."WordDocChangeLog" = outf
}
}
}
else if (updateChangeBars)
{ updateChangeBars = false
ack "Can only update ChangeBar in current module"
}
Skip skCompAttributes = create
string aName
AttrDef atb1,atb2
int i, iSkip = 0, iElems = noElems (dbeAttrDefNameList)
bool bCheck
for (i=0;i<iElems;i++)
{ bCheck = getCheck (dbeAttrDefNameList, i)
if (bCheck)
{ aName = get (dbeAttrDefNameList, i)
atb1 = find(b1,aName)
atb2 = find(b2,aName)
if ((null atb1) or (null atb2))
{ if (null atb1)
infoBox aName " not in later baseline"
else
infoBox aName " not in earlier baseline"
}
else
put(skCompAttributes, iSkip++, aName)
}
}
current = b1 // make sure filtering is off
filtering off // on both sides.
current = b2
filtering off
current = old
Skip absno1 = getAbsnos b1 // build caches of absnos -> objects
Skip absno2 = getAbsnos b2
Object o1, o2
int iObj=0, iMaxObj=0, diffs=0
bool StartInsert = true
for o1 in absno1 do // loop through side 1
iMaxObj++
progressStart(dbBLCompare, "Baseline Compare", "", iMaxObj)
progressMessage("Compare selected attributes of all objects by Identifier")
for o1 in absno1 do // loop through side 1
{ progressStep(iObj++)
Object o2
int i = (int key absno1)
if (find(absno2, i, o2)) // absno exists in other baseline
{ bool ChangeFound = false
for aName in skCompAttributes do
{ ChangeFound = !compareObjects(i, o1, o2, aName) || ChangeFound
}
ChangeFound = oleInsDel(o1,o2) || ChangeFound
if (!ChangeFound)
{ ChangeFound = oleChange(o1,o2)
}
if (ChangeFound)
{ diffs++ // found a difference
if (updateChangeBars)
{ o1."ChangeBar" = true
}
}
else if (updateChangeBars)
{ o1."ChangeBar" = false
}
delete(absno2, i) // remove from dbeListBaseline
}
else
{ if (StartInsert)
{ outFile << "\\pard\\par\\ul \\fs24 Inserted Objects\\ul0\\par \\par "
StartInsert = false
}
outFile << "\\fs20" identifier(o1) " section " lastHeadingNumber(o1) "\\par "
accept o1
if (updateChangeBars)
{ o1."ChangeBar" = true
}
diffs++
}
}
progressStop()
raise (dbBLCompare)
infoBox "Baseline Compare has finished"
if (StartInsert)
{ outFile << "\\pard\\par\\ul \\fs24 Inserted Objects\\ul0\\par \\par "
}
outFile << "\n\\par\\ul \\fs24 Deleted Objects\\ul0\\par \\par "
for o2 in absno2 do // now we can check for objects not in dbeListCurrent
{ int i = (int key absno2)
outFile << "\\fs20" identifier(o2) " section " lastHeadingNumber(o2) "\\par "
accept o2
diffs++
}
delete absno1 // delete caches
delete absno2
delete skCompAttributes
bool doFilter // set to true if differences
if (diffs==0)
{ outFile << "\n\\par \\fs24 no differences found\\par "
doFilter=false
}
else // set filtering on in baselines
{ if (diffs==1)
outFile << "\n\\par \\fs24 one difference found\\par "
else
outFile << "\n\\par \\fs24 " diffs " differences found\\par "
doFilter=true
}
outFile << "\\par }"
close(outFile)
current = b1 // set filters
if (b1 != old)
close b1
// filtering doFilter
// refresh current
current = b2
if (b2 != old)
close b2
// filtering doFilter
// refresh current
current = old // return to former current module
} // applyCompareFunction
//// MAIN PROGRAM ////////////////////////
Module m = current // check calling context
if (null m)
{ ack "program requires current Module"
halt
}
Baseline b
int i=0
for b in m do // count number of baselines
{ i++
}
if (i==0)
{ ack "no baselines to compare"
halt
}
// Now make a dialog for selecting two baselines for comparison
string where = (current Module)."Name"
dbBLCompare = create "Your Company Baseline Compare V. 1.0 startet at Module: \"" where "\""
string strEmptyArr[] = {}
dbeListCurrent = list(dbBLCompare, "Current/Baseline:", 300, i+1 <? 5, strEmptyArr) // make maximum size of 5 elements
dbeListCurrent->"right"->"unattached" // make lists side by side
dbeListBaseline = list(dbBLCompare, "Baseline to compare with:", 300, i+1 <? 5, strEmptyArr)
dbeListBaseline->"left"->"flush"->dbeListCurrent
dbeListBaseline->"top"->"aligned"->dbeListCurrent
dbeListBaseline->"right"->"unattached"
separator (dbBLCompare)
dbeAttrDefNameList = listView(dbBLCompare, listViewOptionCheckboxes , 250, 14, DUMMY_LIST)
dbeAttrDefNameList->"left"->"form"
dbeAttrDefNameList->"right"->"unattached"
dbeAttrAffects = checkBox(dbBLCompare, "", strAffectsArr, 0)
dbeAttrAffects->"top"->"aligned"->dbeAttrDefNameList
dbeAttrAffects->"left"->"flush"->dbeAttrDefNameList
dbeAttrAffects->"right"->"unattached"
inactive (dbeAttrAffects)
dbeAttrCharacter = checkBox(dbBLCompare, "", strCharacterArr, 0)
dbeAttrCharacter->"top"->"flush"->dbeAttrAffects
dbeAttrCharacter->"left"->"flush"->dbeAttrDefNameList
dbeAttrCharacter->"right"->"unattached"
inactive (dbeAttrCharacter)
dbeAttrValidity = checkBox(dbBLCompare, "valid for: ", strValidityArr, 0)
dbeAttrValidity->"top"->"flush"->dbeAttrCharacter
dbeAttrValidity->"left"->"flush"->dbeAttrDefNameList
dbeAttrValidity->"right"->"unattached"
inactive (dbeAttrValidity)
dbeAttrProperty = checkBox(dbBLCompare, "Properties: ", strPropertyArr, 0)
dbeAttrProperty->"top"->"flush"->dbeAttrValidity
dbeAttrProperty->"left"->"flush"->dbeAttrDefNameList
dbeAttrProperty->"right"->"unattached"
inactive (dbeAttrProperty)
dbeAttrType = field (dbBLCompare, "Type: ", "", 27, true)
dbeAttrType->"top"->"spaced"->dbeAttrProperty
dbeAttrType->"left"->"flush"->dbeAttrDefNameList
dbeAttrType->"right"->"unattached"
dbeDefaultValue = field (dbBLCompare, "Default value:", "", 21, true)
dbeDefaultValue->"top"->"flush"->dbeAttrType
dbeDefaultValue->"left"->"flush"->dbeAttrDefNameList
dbeDefaultValue->"right"->"unattached"
dbeAttrTypeList = text(dbBLCompare, "Possible values or defined borders:", "", 215, 142, true)
dbeAttrTypeList->"top"->"spaced"->dbeDefaultValue
dbeAttrTypeList->"left"->"flush"->dbeAttrDefNameList
dbeAttrTypeList->"right"->"unattached"
//dbeAttrTypeList->"bottom"->"unattached"
dbeAttrTypeSelect = toggle(dbBLCompare,"show System and Hidden Attributes", true)
dbeAttrTypeSelect->"top"->"flush"->dbeAttrDefNameList
dbeAttrTypeSelect->"left"->"form"
dbeAttrTypeSelect->"right"->"unattached"
dbeAttrTypeSelect->"bottom"->"unattached"
separator (dbBLCompare)
dbeOutFileLabel = label(dbBLCompare, "Output to:")
dbeOutFileBrowse = fileName(dbBLCompare, "D:\\Project - DOORS Demonstration\\BL_Comp_Result.rtf", "*.rtf", "Rich Text files", false)
dbeChangeBarToggle = toggle(dbBLCompare,"Update ChangeBar attribute", false)
beside (dbBLCompare)
dbeShowDiffToggle = toggle(dbBLCompare,"Show Object Text changes as markup", true)
// dummy
DBE dbeDummy = label(dbBLCompare, "")
dbeDummy->"top"->"spaced"->dbeShowDiffToggle
dbeDummy->"left"->"form"
// Copyright
DBE dbeCopyRight = label(dbBLCompare, "Copyright (C) Your Company Your Town 2005-2007 Confidential. All rights reserved.")
dbeCopyRight->"bottom"->"spaced"->dbeDummy
dbeCopyRight->"left"->"form"
apply(dbBLCompare, "Compare Now", applyCompareFunction)
set(dbeAttrDefNameList, cbDoSetAttrTypes, doNothing, doNothing)
set(dbeAttrTypeSelect, cbSystemSelect)
realize (dbBLCompare, 0, 0) // we realize so that the lists can be populated using insert
insertColumn(dbeAttrDefNameList, 0, "Attribute Name", 200, iconNone)
for b in m do // fill up the baselines skip list with current baselines
{ string str = (major b) "." (minor b) (suffix b)
put(skBaselines, b, str)
insert(dbeListCurrent, 0, str)
insert(dbeListBaseline, 0, str)
}
insert(dbeListCurrent, 0, "current") // put current at head of lists
set(dbeListCurrent, 0)
insert(dbeListBaseline, 0, "current")
set(dbeListBaseline, 1)
showAttributes()
show dbBLCompare // off we go.......
// end of BaselineCompare.dxl

AdWords Script With Divergent Data from Webview

I have the following code on an AdWords script:
var campanha = 'xyz';
function main() {
campanhas = AdWordsApp.campaigns().withCondition("CampaignName = '" + campanha + "'").withCondition('Status = ENABLED').get();
while(campanhas.hasNext()) {
campanha = campanhas.next();
if(campanha.getBiddingStrategyType() != 'ENHANCED_CPC') {
Logger.log('Ajuste de lance da campanha inválido: ' +campanha.getBiddingStrategyType());
continue;
}
palavras = campanha.keywords().withCondition('Status = ENABLED').forDateRange("YESTERDAY").get();
while(palavras.hasNext()) {
palavra = palavras.next();
estatisticas = palavra.getStatsFor('YESTERDAY');
lances = palavra.bidding();
estimativa_primeira = Math.max(palavra.getTopOfPageCpc(), palavra.getFirstPageCpc());
posicao = estatisticas.getAveragePosition();
if (posicao > 1) {
Logger.log(palavra.getText() +" = " +" "+palavra.getTopOfPageCpc()+" "+palavra.getFirstPageCpc());
}
//Logger.log(palavra.getText() + ' = '+lances.getCpc()+" = "+estatisticas.getAveragePosition());
}
}
I expected to retrieve the estimated first page CPC and estimated first position CPC. But the values that I received are diferente from the AdWords webinterface. For exemple, for a given keyword the script returned +xxx +yyyy = 0.12 0.05, when I look those keywords on webinterface I have the following values for 0.12 for estimated first page CPC and 0.41 for estimated first position CPC.

Want several font colors in my cell

Im creating a new cell = new XRTableCell();
I'll show a sample of my code.
I always ending up with the same color in my cell, even if I change it in my "If".
foreach (TaskTime tt in di.TaskTimes[i])
{
.....
TimeToAdd = ClassLibrary.Utils.GetTimeStringFromSec(tt.FromSec % 86400) + " - " + ClassLibrary.Utils.GetTimeStringFromSec(tt.UntilSec % 86400) + " (" + tt.Abbreviation+ ")";
if (taskTimeTextBox.Text.Length > 0)
taskTimeTextBox.Text += "\n";
taskTimeTextBox.Text += TimeToAdd;
if (tt.OnOtherCostDivision)
{
taskTimeTextBox.SelectionStart = taskTimeTextBox.Find(TimeToAdd);
taskTimeTextBox.SelectionFont = new Font("Calibri", 9, FontStyle.Italic);
taskTimeTextBox.SelectionColor = Color.Gray;
}
else
{
taskTimeTextBox.SelectionStart = taskTimeTextBox.Find(TimeToAdd);
taskTimeTextBox.SelectionFont = new Font("Calibri", 9, FontStyle.Italic);
taskTimeTextBox.SelectionColor = Color.Blue;
}
richTxtObject.Rtf = taskTimeTextBox.Rtf;
cell.Controls.Add(richTxtObject);
}
row.Cells.Add(cell);
Soulved it! Didn't worked when I had it this way "taskTimeTextBox.Text += xxxxxxxx ". So I made a list of string, saved my text in if it were "onOtherCostDivision". Later on I hade to loop true my list and see if the final taskTimeTextBox.Text had the text in it and in that cause I added the color.
foreach (var task in taskCostDivList)
{
if (taskTimeTextBox.Text.Contains(task))
{
taskTimeTextBox.SelectionStart = taskTimeTextBox.Find(task);
taskTimeTextBox.Font = new Font("Calibri", 9, FontStyle.Italic);
taskTimeTextBox.SelectionColor = Color.Gray;
}
else
{
taskTimeTextBox.Font = new Font("Calibri", 9, FontStyle.Regular);
taskTimeTextBox.SelectionColor = Color.Black;
}
}

Resources